//
//  URL+Ext.swift
//  KLExtension
//
//  Created by nkl on 2023/6/29.
//

import Foundation

public extension URL {
    public func urlParameter(param: String) -> String {
        guard let components = URLComponents(url: self, resolvingAgainstBaseURL: true),
              let queryItems = components.queryItems else { return "" }
        let sss = queryItems.reduce(into: [String: String]()) { result, item in
            result[item.name] = item.value
        }
        if let value = sss[param] {
            return value
        }
        return ""
    }
}
